"use strict";
cc._RF.push(module, '5d9bd9nku9DpatZbpKOJolf', 'level_peopleArcheryBox');
// scripts/levelBundles/level_PeopleArchery/unit/level_peopleArcheryBox.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameEngine_1 = require("../../../engines/gameEngine");
var CsvFileKind_1 = require("../../../engines/libs/CsvFileKind");
var level_PeopleArcheryUnitBase_1 = require("../base/level_PeopleArcheryUnitBase");
var peopleArcheryConst_1 = require("../const/peopleArcheryConst");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var level_peopleArcheryBox = /** @class */ (function (_super) {
    __extends(level_peopleArcheryBox, _super);
    function level_peopleArcheryBox() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.type = 0;
        _this.lbText = null;
        _this.showSp = null;
        _this.showSps = [];
        _this.waveData = null;
        _this.datas = [];
        return _this;
    }
    /**绑定数据 */
    level_peopleArcheryBox.prototype.bindData = function (type, waveData) {
        this.type = type;
        this.waveData = waveData;
        this.loadDatas();
        this.refrenshText();
        this.refrenshShow();
    };
    level_peopleArcheryBox.prototype.refrenshText = function () {
        var str = gameEngine_1.default.getManagers().peopleArcheryManager.getOptionText(this.datas[0]);
        this.lbText.string = str;
    };
    level_peopleArcheryBox.prototype.refrenshShow = function () {
        this.showSp.spriteFrame = this.type == 1 ? this.showSps[1] : this.showSps[0];
    };
    level_peopleArcheryBox.prototype.update = function (dt) {
        if (this.level.gamePauseFlag) {
            return;
        }
        var moveDis = this.level.getRoleMoveSpd() * dt;
        this.node.y -= moveDis;
        this.autoDeath();
        _super.prototype.update.call(this, dt);
    };
    level_peopleArcheryBox.prototype.onCollisionEnter = function (other, self) {
        switch (other.tag) {
            case peopleArcheryConst_1.peopleArcheryUnitTag.people: {
                gameEngine_1.default.getManagers().soundMgr.playSound("peopleArcherySound/Door");
                this.openData();
                this.unitDeath();
                break;
            }
        }
    };
    level_peopleArcheryBox.prototype.loadDatas = function () {
        var boxTypeId = "";
        switch (this.type) {
            case 1: {
                boxTypeId = this.waveData.big_drop_type;
                break;
            }
            case 2: {
                boxTypeId = this.waveData.middle_drop_type;
            }
            case 3: {
                boxTypeId = this.waveData.little_drop_type;
                break;
            }
        }
        var data = gameEngine_1.default.getManagers().csvDataManager.getCsvDataItem(CsvFileKind_1.CsvFileKind.CsvFile.peopleArcheryBox, boxTypeId);
        var dropType = data["drop_type"];
        // 箱子打开动画
        // 不需要打开界面
        this.datas = this.level.getOptions(dropType, 1);
    };
    level_peopleArcheryBox.prototype.openData = function () {
        // 不需要打开界面
        this.level.parseDataAddPeople(this.datas[0]);
    };
    __decorate([
        property({ type: cc.Label, tooltip: "箱子文本" })
    ], level_peopleArcheryBox.prototype, "lbText", void 0);
    __decorate([
        property({ type: cc.Sprite, tooltip: "显示图片" })
    ], level_peopleArcheryBox.prototype, "showSp", void 0);
    __decorate([
        property({ type: cc.SpriteFrame, tooltip: "显示的图片" })
    ], level_peopleArcheryBox.prototype, "showSps", void 0);
    level_peopleArcheryBox = __decorate([
        ccclass
    ], level_peopleArcheryBox);
    return level_peopleArcheryBox;
}(level_PeopleArcheryUnitBase_1.default));
exports.default = level_peopleArcheryBox;

cc._RF.pop();